<template>
    <el-dialog
            title="外部数据源信息"
            :visible.sync="modelInfoVisible"
            :close-on-click-modal="false"
            width="40%"
            v-dialogDrag>
        <div style="padding-left: 0.5%;padding-top:1%" v-if="type=='api'">
            <!--<el-row class="step" v-for="(key, value) in infoData" :key="key">-->
            <!--<span style="font-size: 20px;">{{key}}</span>-->
            <!--<span style="font-size: 20px;">{{value}}</span>-->
            <!--</el-row>-->
            <!--<p>用户ID：{{this.infoData.userid}}</p>-->
            <p>API：{{this.infoData.connectionName}}</p>
            <p>参数：{{this.infoData.params}}</p>
        </div>
        <div style="padding-left: 0.5%;padding-top:1%" v-if="type!='api'">
            <!--<el-row class="step" v-for="(key, value) in infoData" :key="key">-->
                <!--<span style="font-size: 20px;">{{key}}</span>-->
                <!--<span style="font-size: 20px;">{{value}}</span>-->
            <!--</el-row>-->
            <!--<p>用户ID：{{this.infoData.userid}}</p>-->
            <p>数据名称：{{this.infoData.dataName}}</p>
            <p>源数据IP：{{this.infoData.IP}}</p>
            <p>所属数据库：{{this.infoData.database}}</p>
            <p>对应数据表名称：{{this.infoData.tableName}}</p>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        name: "modelInfoDialog",
        data() {
            return {
                modelInfoVisible: false,
                url: '',
                infoData: {},
                type:''
            }
        },
        methods: {
            getModelInfo() {
                let that = this;
                this.infoData = {};
                this.$axios.post(that.url).then(res => {
                    that.infoData = res.body;

                }).catch(function (error) {
                    console.log(error);
                    that.$message({
                        type: 'warning',
                        message: '外部数据集信息获取失败！'
                    })
                })
            }
        },
        created() {
            let that = this;
            this.$Bus.$on('externalDataInfo', res => {
                that.url = res.url;
                that.modelInfoVisible = res.visible;
                that.type=res.type;
                that.getModelInfo();
            })
        }
    }
</script>

<style>
    .el-dialog__body {
        max-height: 600px;
        overflow: auto;
    }
</style>